<?php

namespace Base\WebBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Base\WebBundle\Entity\Menu;


class DefaultController extends Controller
{
    public function indexAction()
    {
        return $this->render('BaseWebBundle:Default:index.html.twig', array());
    }
    
    public function menusettingsAction(Request $request) {
    	$menu = new Menu();
    	$form = $this->createFormBuilder($menu)
		    	->add('name', 'text')
		    	->add('href', 'text')
		    	->add('description', 'text')
		    	->add('save', 'submit')
		    	->getForm();
    	$form->handleRequest($request);
    	if ($form->isValid()) {
    		$menu = $form->getData();
    		$em = $this->getDoctrine()->getManager();
    		$em->persist($menu);
    		$em->flush();
    	}
    	return $this->render('BaseWebBundle:Default:menusettings.html.twig', array('form' => $form->createView()));
    }
}
